APP_PATH=/home/app/deploy
APP_ENV=deploy
DOCKER_NAME=development.docker.19ego.cn:5000/intelligentcall/ic_web

echo '正在删除旧项目，更新新项目...'

rm -rf $APP_PATH/ic_web
cd $APP_PATH
git clone git@codeup.aliyun.com:640fcbf2e9f200d37adc44ae/szdy/human-machine-cooperation/ic_web.git
cd $APP_PATH/ic_web
git checkout feature-yore

echo '代码拉取切换完成'

RELEASE_VERSION=5.0.3
# RELEASE_VERSION=4.1.9

# 打包
node -v
npm -v
pnpm -v
pnpm install
npm run build:$APP_ENV

echo '代码打包完成'

# 打镜像包并推送镜像仓库
docker build -t $DOCKER_NAME:$RELEASE_VERSION .

echo '镜像打包完成'

#部署
 BACK_END_SERVICES="https://222.186.101.212:8082"
 BACK_END_SERVICES_WEB_SOCKET="222.186.101.212:8082"
 BACK_END_SERVICES_WEB_DEBUG="0"
 BACK_END_SERVICES_WEB_LOGIN_STYLE=" "

 docker rm -f ic_web
 docker rmi -f docker images -aq test.docker.19ego.cn:5000/intelligentcall/ic_web:
 docker run -d --name ic_web \
            --restart=always \
            --ulimit nofile=5000:5000 \
            -e BACK_END_SERVICES=$BACK_END_SERVICES \
            -e BACK_END_SERVICES_WEB_SOCKET=$BACK_END_SERVICES_WEB_SOCKET \
            -e BACK_END_SERVICES_WEB_DEBUG=$BACK_END_SERVICES_WEB_DEBUG \
            -e BACK_END_SERVICES_WEB_LOGIN_STYLE=$BACK_END_SERVICES_WEB_LOGIN_STYLE \
            -m 2g \
            -p 6080:80 \
            -v /log/applog/ic_web:/log \
            $DOCKER_NAME:$RELEASE_VERSION

echo 'docker部署完成 >>>>>>>>> ✅'
